#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@Author: kindey
@Date: 2025/7/14
@Description: 
"""
import json
import os

class ConfigLoader:
    # 静态变量存储配置
    _config = None

    @staticmethod
    def load_config():
        if ConfigLoader._config is None:
            # 获取当前文件所在目录
            current_dir = os.path.dirname(__file__)
            # 获取上上级目录
            parent_dir = os.path.dirname(os.path.dirname(current_dir))
            # 构造配置文件路径
            config_path = os.path.join(parent_dir, 'resources', 'config.json')

            with open(config_path, 'r', encoding='utf-8') as f:
                ConfigLoader._config = json.load(f)
        return ConfigLoader._config

    @staticmethod
    def get_config():
        if ConfigLoader._config is None:
            raise ValueError("Config not loaded yet. Please call load_config() first.")
        return ConfigLoader._config

# if __name__ == "__main__":
#     ConfigLoader.load_config()
#     config = ConfigLoader.get_config()
#     print(config['data']['train_path'])
#     print(config['model']['name'])